package com.wqm.cn.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
/**
*
*  @author wqm
*/
public class REPORTDATASOURCEATTR implements Serializable {

    private static final long serialVersionUID = 1607691486479L;


    /**
    * 主键
    * 数据源属性ID
    * isNullAble:0
    */
    private Integer dATAATTRID;

    /**
    * 数据表栏位名
    * isNullAble:0
    */
    private String cOLUMNNAME;

    /**
    * 是否可视
    * isNullAble:1,defaultVal:Y
    */
    private String iSVISIABLE;

    /**
    * 是否作为过滤器
    * isNullAble:1,defaultVal:Y
    */
    private String iSFILTER;

    /**
    * 数据源ID
    * isNullAble:0
    */
    private Integer dATAID;


    public void setDATAATTRID(Integer dATAATTRID){this.dATAATTRID = dATAATTRID;}

    public Integer getDATAATTRID(){return this.dATAATTRID;}

    public void setCOLUMNNAME(String cOLUMNNAME){this.cOLUMNNAME = cOLUMNNAME;}

    public String getCOLUMNNAME(){return this.cOLUMNNAME;}

    public void setISVISIABLE(String iSVISIABLE){this.iSVISIABLE = iSVISIABLE;}

    public String getISVISIABLE(){return this.iSVISIABLE;}

    public void setISFILTER(String iSFILTER){this.iSFILTER = iSFILTER;}

    public String getISFILTER(){return this.iSFILTER;}

    public void setDATAID(Integer dATAID){this.dATAID = dATAID;}

    public Integer getDATAID(){return this.dATAID;}
    @Override
    public String toString() {
        return "REPORTDATASOURCEATTR{" +
                "dATAATTRID='" + dATAATTRID + '\'' +
                "cOLUMNNAME='" + cOLUMNNAME + '\'' +
                "iSVISIABLE='" + iSVISIABLE + '\'' +
                "iSFILTER='" + iSFILTER + '\'' +
                "dATAID='" + dATAID + '\'' +
            '}';
    }

    public static Builder Build(){return new Builder();}

    public static ConditionBuilder ConditionBuild(){return new ConditionBuilder();}

    public static UpdateBuilder UpdateBuild(){return new UpdateBuilder();}

    public static QueryBuilder QueryBuild(){return new QueryBuilder();}

    public static class UpdateBuilder {

        private REPORTDATASOURCEATTR set;

        private ConditionBuilder where;

        public UpdateBuilder set(REPORTDATASOURCEATTR set){
            this.set = set;
            return this;
        }

        public REPORTDATASOURCEATTR getSet(){
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where){
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere(){
            return this.where;
        }

        public UpdateBuilder build(){
            return this;
        }
    }

    public static class QueryBuilder extends REPORTDATASOURCEATTR{
        /**
        * 需要返回的列
        */
        private Map<String,Object> fetchFields;

        public Map<String,Object> getFetchFields(){return this.fetchFields;}

        private List<Integer> dATAATTRIDList;

        public List<Integer> getDATAATTRIDList(){return this.dATAATTRIDList;}

        private Integer dATAATTRIDSt;

        private Integer dATAATTRIDEd;

        public Integer getDATAATTRIDSt(){return this.dATAATTRIDSt;}

        public Integer getDATAATTRIDEd(){return this.dATAATTRIDEd;}

        private List<String> cOLUMNNAMEList;

        public List<String> getCOLUMNNAMEList(){return this.cOLUMNNAMEList;}


        private List<String> fuzzyCOLUMNNAME;

        public List<String> getFuzzyCOLUMNNAME(){return this.fuzzyCOLUMNNAME;}

        private List<String> rightFuzzyCOLUMNNAME;

        public List<String> getRightFuzzyCOLUMNNAME(){return this.rightFuzzyCOLUMNNAME;}
        private List<String> iSVISIABLEList;

        public List<String> getISVISIABLEList(){return this.iSVISIABLEList;}


        private List<String> fuzzyISVISIABLE;

        public List<String> getFuzzyISVISIABLE(){return this.fuzzyISVISIABLE;}

        private List<String> rightFuzzyISVISIABLE;

        public List<String> getRightFuzzyISVISIABLE(){return this.rightFuzzyISVISIABLE;}
        private List<String> iSFILTERList;

        public List<String> getISFILTERList(){return this.iSFILTERList;}


        private List<String> fuzzyISFILTER;

        public List<String> getFuzzyISFILTER(){return this.fuzzyISFILTER;}

        private List<String> rightFuzzyISFILTER;

        public List<String> getRightFuzzyISFILTER(){return this.rightFuzzyISFILTER;}
        private List<Integer> dATAIDList;

        public List<Integer> getDATAIDList(){return this.dATAIDList;}

        private Integer dATAIDSt;

        private Integer dATAIDEd;

        public Integer getDATAIDSt(){return this.dATAIDSt;}

        public Integer getDATAIDEd(){return this.dATAIDEd;}

        private QueryBuilder (){
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder dATAATTRIDBetWeen(Integer dATAATTRIDSt,Integer dATAATTRIDEd){
            this.dATAATTRIDSt = dATAATTRIDSt;
            this.dATAATTRIDEd = dATAATTRIDEd;
            return this;
        }

        public QueryBuilder dATAATTRIDGreaterEqThan(Integer dATAATTRIDSt){
            this.dATAATTRIDSt = dATAATTRIDSt;
            return this;
        }
        public QueryBuilder dATAATTRIDLessEqThan(Integer dATAATTRIDEd){
            this.dATAATTRIDEd = dATAATTRIDEd;
            return this;
        }


        public QueryBuilder dATAATTRID(Integer dATAATTRID){
            setDATAATTRID(dATAATTRID);
            return this;
        }

        public QueryBuilder dATAATTRIDList(Integer ... dATAATTRID){
            this.dATAATTRIDList = solveNullList(dATAATTRID);
            return this;
        }

        public QueryBuilder dATAATTRIDList(List<Integer> dATAATTRID){
            this.dATAATTRIDList = dATAATTRID;
            return this;
        }

        public QueryBuilder fetchDATAATTRID(){
            setFetchFields("fetchFields","dATAATTRID");
            return this;
        }

        public QueryBuilder excludeDATAATTRID(){
            setFetchFields("excludeFields","dATAATTRID");
            return this;
        }

        public QueryBuilder fuzzyCOLUMNNAME (List<String> fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = fuzzyCOLUMNNAME;
            return this;
        }

        public QueryBuilder fuzzyCOLUMNNAME (String ... fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = solveNullList(fuzzyCOLUMNNAME);
            return this;
        }

        public QueryBuilder rightFuzzyCOLUMNNAME (List<String> rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = rightFuzzyCOLUMNNAME;
            return this;
        }

        public QueryBuilder rightFuzzyCOLUMNNAME (String ... rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = solveNullList(rightFuzzyCOLUMNNAME);
            return this;
        }

        public QueryBuilder cOLUMNNAME(String cOLUMNNAME){
            setCOLUMNNAME(cOLUMNNAME);
            return this;
        }

        public QueryBuilder cOLUMNNAMEList(String ... cOLUMNNAME){
            this.cOLUMNNAMEList = solveNullList(cOLUMNNAME);
            return this;
        }

        public QueryBuilder cOLUMNNAMEList(List<String> cOLUMNNAME){
            this.cOLUMNNAMEList = cOLUMNNAME;
            return this;
        }

        public QueryBuilder fetchCOLUMNNAME(){
            setFetchFields("fetchFields","cOLUMNNAME");
            return this;
        }

        public QueryBuilder excludeCOLUMNNAME(){
            setFetchFields("excludeFields","cOLUMNNAME");
            return this;
        }

        public QueryBuilder fuzzyISVISIABLE (List<String> fuzzyISVISIABLE){
            this.fuzzyISVISIABLE = fuzzyISVISIABLE;
            return this;
        }

        public QueryBuilder fuzzyISVISIABLE (String ... fuzzyISVISIABLE){
            this.fuzzyISVISIABLE = solveNullList(fuzzyISVISIABLE);
            return this;
        }

        public QueryBuilder rightFuzzyISVISIABLE (List<String> rightFuzzyISVISIABLE){
            this.rightFuzzyISVISIABLE = rightFuzzyISVISIABLE;
            return this;
        }

        public QueryBuilder rightFuzzyISVISIABLE (String ... rightFuzzyISVISIABLE){
            this.rightFuzzyISVISIABLE = solveNullList(rightFuzzyISVISIABLE);
            return this;
        }

        public QueryBuilder iSVISIABLE(String iSVISIABLE){
            setISVISIABLE(iSVISIABLE);
            return this;
        }

        public QueryBuilder iSVISIABLEList(String ... iSVISIABLE){
            this.iSVISIABLEList = solveNullList(iSVISIABLE);
            return this;
        }

        public QueryBuilder iSVISIABLEList(List<String> iSVISIABLE){
            this.iSVISIABLEList = iSVISIABLE;
            return this;
        }

        public QueryBuilder fetchISVISIABLE(){
            setFetchFields("fetchFields","iSVISIABLE");
            return this;
        }

        public QueryBuilder excludeISVISIABLE(){
            setFetchFields("excludeFields","iSVISIABLE");
            return this;
        }

        public QueryBuilder fuzzyISFILTER (List<String> fuzzyISFILTER){
            this.fuzzyISFILTER = fuzzyISFILTER;
            return this;
        }

        public QueryBuilder fuzzyISFILTER (String ... fuzzyISFILTER){
            this.fuzzyISFILTER = solveNullList(fuzzyISFILTER);
            return this;
        }

        public QueryBuilder rightFuzzyISFILTER (List<String> rightFuzzyISFILTER){
            this.rightFuzzyISFILTER = rightFuzzyISFILTER;
            return this;
        }

        public QueryBuilder rightFuzzyISFILTER (String ... rightFuzzyISFILTER){
            this.rightFuzzyISFILTER = solveNullList(rightFuzzyISFILTER);
            return this;
        }

        public QueryBuilder iSFILTER(String iSFILTER){
            setISFILTER(iSFILTER);
            return this;
        }

        public QueryBuilder iSFILTERList(String ... iSFILTER){
            this.iSFILTERList = solveNullList(iSFILTER);
            return this;
        }

        public QueryBuilder iSFILTERList(List<String> iSFILTER){
            this.iSFILTERList = iSFILTER;
            return this;
        }

        public QueryBuilder fetchISFILTER(){
            setFetchFields("fetchFields","iSFILTER");
            return this;
        }

        public QueryBuilder excludeISFILTER(){
            setFetchFields("excludeFields","iSFILTER");
            return this;
        }

        public QueryBuilder dATAIDBetWeen(Integer dATAIDSt,Integer dATAIDEd){
            this.dATAIDSt = dATAIDSt;
            this.dATAIDEd = dATAIDEd;
            return this;
        }

        public QueryBuilder dATAIDGreaterEqThan(Integer dATAIDSt){
            this.dATAIDSt = dATAIDSt;
            return this;
        }
        public QueryBuilder dATAIDLessEqThan(Integer dATAIDEd){
            this.dATAIDEd = dATAIDEd;
            return this;
        }


        public QueryBuilder dATAID(Integer dATAID){
            setDATAID(dATAID);
            return this;
        }

        public QueryBuilder dATAIDList(Integer ... dATAID){
            this.dATAIDList = solveNullList(dATAID);
            return this;
        }

        public QueryBuilder dATAIDList(List<Integer> dATAID){
            this.dATAIDList = dATAID;
            return this;
        }

        public QueryBuilder fetchDATAID(){
            setFetchFields("fetchFields","dATAID");
            return this;
        }

        public QueryBuilder excludeDATAID(){
            setFetchFields("excludeFields","dATAID");
            return this;
        }
        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll(){
            this.fetchFields.put("AllFields",true);
            return this;
        }

        public QueryBuilder addField(String ... fields){
            List<String> list = new ArrayList<>();
            if (fields != null){
                for (String field : fields){
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields",list);
            return this;
        }
        @SuppressWarnings("unchecked")
        private void setFetchFields(String key,String val){
            Map<String,Boolean> fields= (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null){
                fields = new HashMap<>();
            }
            fields.put(val,true);
            this.fetchFields.put(key,fields);
        }

        public REPORTDATASOURCEATTR build(){return this;}
    }


    public static class ConditionBuilder{
        private List<Integer> dATAATTRIDList;

        public List<Integer> getDATAATTRIDList(){return this.dATAATTRIDList;}

        private Integer dATAATTRIDSt;

        private Integer dATAATTRIDEd;

        public Integer getDATAATTRIDSt(){return this.dATAATTRIDSt;}

        public Integer getDATAATTRIDEd(){return this.dATAATTRIDEd;}

        private List<String> cOLUMNNAMEList;

        public List<String> getCOLUMNNAMEList(){return this.cOLUMNNAMEList;}


        private List<String> fuzzyCOLUMNNAME;

        public List<String> getFuzzyCOLUMNNAME(){return this.fuzzyCOLUMNNAME;}

        private List<String> rightFuzzyCOLUMNNAME;

        public List<String> getRightFuzzyCOLUMNNAME(){return this.rightFuzzyCOLUMNNAME;}
        private List<String> iSVISIABLEList;

        public List<String> getISVISIABLEList(){return this.iSVISIABLEList;}


        private List<String> fuzzyISVISIABLE;

        public List<String> getFuzzyISVISIABLE(){return this.fuzzyISVISIABLE;}

        private List<String> rightFuzzyISVISIABLE;

        public List<String> getRightFuzzyISVISIABLE(){return this.rightFuzzyISVISIABLE;}
        private List<String> iSFILTERList;

        public List<String> getISFILTERList(){return this.iSFILTERList;}


        private List<String> fuzzyISFILTER;

        public List<String> getFuzzyISFILTER(){return this.fuzzyISFILTER;}

        private List<String> rightFuzzyISFILTER;

        public List<String> getRightFuzzyISFILTER(){return this.rightFuzzyISFILTER;}
        private List<Integer> dATAIDList;

        public List<Integer> getDATAIDList(){return this.dATAIDList;}

        private Integer dATAIDSt;

        private Integer dATAIDEd;

        public Integer getDATAIDSt(){return this.dATAIDSt;}

        public Integer getDATAIDEd(){return this.dATAIDEd;}


        public ConditionBuilder dATAATTRIDBetWeen(Integer dATAATTRIDSt,Integer dATAATTRIDEd){
            this.dATAATTRIDSt = dATAATTRIDSt;
            this.dATAATTRIDEd = dATAATTRIDEd;
            return this;
        }

        public ConditionBuilder dATAATTRIDGreaterEqThan(Integer dATAATTRIDSt){
            this.dATAATTRIDSt = dATAATTRIDSt;
            return this;
        }
        public ConditionBuilder dATAATTRIDLessEqThan(Integer dATAATTRIDEd){
            this.dATAATTRIDEd = dATAATTRIDEd;
            return this;
        }


        public ConditionBuilder dATAATTRIDList(Integer ... dATAATTRID){
            this.dATAATTRIDList = solveNullList(dATAATTRID);
            return this;
        }

        public ConditionBuilder dATAATTRIDList(List<Integer> dATAATTRID){
            this.dATAATTRIDList = dATAATTRID;
            return this;
        }

        public ConditionBuilder fuzzyCOLUMNNAME (List<String> fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = fuzzyCOLUMNNAME;
            return this;
        }

        public ConditionBuilder fuzzyCOLUMNNAME (String ... fuzzyCOLUMNNAME){
            this.fuzzyCOLUMNNAME = solveNullList(fuzzyCOLUMNNAME);
            return this;
        }

        public ConditionBuilder rightFuzzyCOLUMNNAME (List<String> rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = rightFuzzyCOLUMNNAME;
            return this;
        }

        public ConditionBuilder rightFuzzyCOLUMNNAME (String ... rightFuzzyCOLUMNNAME){
            this.rightFuzzyCOLUMNNAME = solveNullList(rightFuzzyCOLUMNNAME);
            return this;
        }

        public ConditionBuilder cOLUMNNAMEList(String ... cOLUMNNAME){
            this.cOLUMNNAMEList = solveNullList(cOLUMNNAME);
            return this;
        }

        public ConditionBuilder cOLUMNNAMEList(List<String> cOLUMNNAME){
            this.cOLUMNNAMEList = cOLUMNNAME;
            return this;
        }

        public ConditionBuilder fuzzyISVISIABLE (List<String> fuzzyISVISIABLE){
            this.fuzzyISVISIABLE = fuzzyISVISIABLE;
            return this;
        }

        public ConditionBuilder fuzzyISVISIABLE (String ... fuzzyISVISIABLE){
            this.fuzzyISVISIABLE = solveNullList(fuzzyISVISIABLE);
            return this;
        }

        public ConditionBuilder rightFuzzyISVISIABLE (List<String> rightFuzzyISVISIABLE){
            this.rightFuzzyISVISIABLE = rightFuzzyISVISIABLE;
            return this;
        }

        public ConditionBuilder rightFuzzyISVISIABLE (String ... rightFuzzyISVISIABLE){
            this.rightFuzzyISVISIABLE = solveNullList(rightFuzzyISVISIABLE);
            return this;
        }

        public ConditionBuilder iSVISIABLEList(String ... iSVISIABLE){
            this.iSVISIABLEList = solveNullList(iSVISIABLE);
            return this;
        }

        public ConditionBuilder iSVISIABLEList(List<String> iSVISIABLE){
            this.iSVISIABLEList = iSVISIABLE;
            return this;
        }

        public ConditionBuilder fuzzyISFILTER (List<String> fuzzyISFILTER){
            this.fuzzyISFILTER = fuzzyISFILTER;
            return this;
        }

        public ConditionBuilder fuzzyISFILTER (String ... fuzzyISFILTER){
            this.fuzzyISFILTER = solveNullList(fuzzyISFILTER);
            return this;
        }

        public ConditionBuilder rightFuzzyISFILTER (List<String> rightFuzzyISFILTER){
            this.rightFuzzyISFILTER = rightFuzzyISFILTER;
            return this;
        }

        public ConditionBuilder rightFuzzyISFILTER (String ... rightFuzzyISFILTER){
            this.rightFuzzyISFILTER = solveNullList(rightFuzzyISFILTER);
            return this;
        }

        public ConditionBuilder iSFILTERList(String ... iSFILTER){
            this.iSFILTERList = solveNullList(iSFILTER);
            return this;
        }

        public ConditionBuilder iSFILTERList(List<String> iSFILTER){
            this.iSFILTERList = iSFILTER;
            return this;
        }

        public ConditionBuilder dATAIDBetWeen(Integer dATAIDSt,Integer dATAIDEd){
            this.dATAIDSt = dATAIDSt;
            this.dATAIDEd = dATAIDEd;
            return this;
        }

        public ConditionBuilder dATAIDGreaterEqThan(Integer dATAIDSt){
            this.dATAIDSt = dATAIDSt;
            return this;
        }
        public ConditionBuilder dATAIDLessEqThan(Integer dATAIDEd){
            this.dATAIDEd = dATAIDEd;
            return this;
        }


        public ConditionBuilder dATAIDList(Integer ... dATAID){
            this.dATAIDList = solveNullList(dATAID);
            return this;
        }

        public ConditionBuilder dATAIDList(List<Integer> dATAID){
            this.dATAIDList = dATAID;
            return this;
        }

        private <T>List<T> solveNullList(T ... objs){
            if (objs != null){
            List<T> list = new ArrayList<>();
                for (T item : objs){
                    if (item != null){
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build(){return this;}
    }

    public static class Builder {

        private REPORTDATASOURCEATTR obj;

        public Builder(){
            this.obj = new REPORTDATASOURCEATTR();
        }

        public Builder dATAATTRID(Integer dATAATTRID){
            this.obj.setDATAATTRID(dATAATTRID);
            return this;
        }
        public Builder cOLUMNNAME(String cOLUMNNAME){
            this.obj.setCOLUMNNAME(cOLUMNNAME);
            return this;
        }
        public Builder iSVISIABLE(String iSVISIABLE){
            this.obj.setISVISIABLE(iSVISIABLE);
            return this;
        }
        public Builder iSFILTER(String iSFILTER){
            this.obj.setISFILTER(iSFILTER);
            return this;
        }
        public Builder dATAID(Integer dATAID){
            this.obj.setDATAID(dATAID);
            return this;
        }
        public REPORTDATASOURCEATTR build(){return obj;}
    }

}
